import { isWechat } from './platform';

const DEFAULT_NAVBAR_HEIGHT = 48;
const DEFAULT_STATUS_BAR_HEIGHT = 22;

/**
 * 获取导航栏高度
 * @param {boolean} withStatusBar 是否包含状态栏高度，默认 true
 * @returns {number} 导航栏高度
 */
export function getNavbarHeight(withStatusBar: boolean = true): number {
  if (!withStatusBar) {
    return DEFAULT_NAVBAR_HEIGHT;
  }

  let statusBarHeight = uni.getWindowInfo().statusBarHeight;

  statusBarHeight = statusBarHeight ?? DEFAULT_STATUS_BAR_HEIGHT;

  return statusBarHeight + DEFAULT_NAVBAR_HEIGHT + 20;
}
